//
//  MenuLayer.m
//  Galaxy
//
//  Created by antl on 1/28/13.
//  Copyright (c) 2013 __MyCompanyName__. All rights reserved.
//

#import "MenuLayer.h"
#import "ChoiceMapScene.h"
@implementation MenuLayer
-(id) init
{
	if(self==[super init])
	{
        [self initBackground];
    }
    return self;
}
-(void)dealloc
{
    [super dealloc];
}

#pragma mark - INIT-
-(void)initBackground
{
    /// ADD BACKGROUND GAME
    [self DrawImageSpritebyLayer:self andFileName:@"bg_menu.png" atPosition:ccp(0,0) withZ:0 andScale:0 AnchorPoint:ccp(0,0)];
    [self DrawImageSpritebyLayer:self andFileName:@"shootthesexygirlpanels.png" atPosition:ccp(10,350) withZ:0 andScale:0 AnchorPoint:ccp(0,0)];
    
    
    /// ADD MENU
    
    //playing game
    CCMenuItemImage *playGame=[CCMenuItemImage itemWithNormalImage:@"btblank.png" selectedImage:@"btblank_hover.png" target:self selector:@selector(clickButton:)];
    playGame.tag=tagPlaying;
    [playGame setAnchorPoint:ccp(0,0)];
    playGame.position=ccp(100,220);
    /// galary
    CCMenuItemImage *galary=[CCMenuItemImage itemWithNormalImage:@"btblank.png" selectedImage:@"btblank_hover.png" target:self selector:@selector(clickButton:)];
    galary.tag=tagbtGalary;
    [galary setAnchorPoint:ccp(0,0)];
     galary.position=ccp(100,150);
    /// more game
    CCMenuItemImage *more=[CCMenuItemImage itemWithNormalImage:@"btblank.png" selectedImage:@"btblank_hover.png" target:self selector:@selector(clickButton:)];
    more.tag=tagbtMore;
    [more setAnchorPoint:ccp(0,0)];
    more.position=ccp(20,80);
    // top app
    CCMenuItemImage *topApp=[CCMenuItemImage itemWithNormalImage:@"btblank.png" selectedImage:@"btblank_hover.png" target:self selector:@selector(clickButton:)];
    topApp.tag=tagTopApp;
    [topApp setAnchorPoint:ccp(0,0)];
    topApp.position=ccp(180,80);
    CCMenu * iMenu=[CCMenu menuWithItems:playGame,galary,more,topApp,nil];
    [iMenu setAnchorPoint:ccp(0,0)];
    iMenu.position=ccp(0,0);
    [self addChild:iMenu];
    
    
    ///// add stroke text
    ///play
    
    [self addStrokeWithText:@"PLAY" andPosition:ccp(-35,-40)];
    [self addStrokeWithText:@"GALARY" andPosition:ccp(-35,-110)];
    [self addStrokeWithText:@"MORE" andPosition:ccp(-115,-180)];
    [self addStrokeWithText:@"TOP APP" andPosition:ccp(45,-180)];  
}
-(void)addStrokeWithText:(NSString*)strText andPosition:(CGPoint)P
{
    CCLabelTTF *text=[CCLabelTTF labelWithString:[NSString stringWithFormat:@"%@",strText] dimensions:CGSizeMake(400, 300) hAlignment:kCCTextAlignmentCenter fontName:@"Arial" fontSize:28];
    [text setColor:ccRED];//ccc3(24,70,168)
    [text setAnchorPoint:ccp(0,0)];
    text.position=P;
    
    CCRenderTexture* stroke = [MenuItemWithStroke createStroke:text  size:1 color:ccWHITE];
    [stroke setAnchorPoint:ccp(0,0)];
    [self addChild:stroke z:10];
    [self addChild:text z:10];
}
-(void)clickButton:(id)sender
{
    CCMenuItemImage *item=(CCMenuItemImage*)sender;
    switch (item.tag) {
        case tagPlaying:
            //// playing 
            [self changePageWithScene:[ChoiceMapScene node] type:ShrinkGrow];
            break;
        case tagbtGalary:
            //// Options 
            break;
        case tagbtMore:
            //// Options 
            break;
        case tagTopApp:
            //// Options 
            break;
        default:
            break;
    }
}

@end
